package com.extra;

public class Solution66 {
    public int[] plusOne(int[] digits) {
        int i = digits.length - 1;
        while (i >= 0) {
            digits[i]++;
            digits[i] %= 10;
            if (digits[i] != 0) return digits;
            i--;
        }
        digits = new int[digits.length + 1];
        digits[0] = 1;
        return digits;
    }
}
